//
//  ShowNavViewController.m
//  testStatusBar
//
//  Created by jianyong.wang on 2017/5/17.
//  Copyright © 2017年 jianyong.wang. All rights reserved.
//

#import "ShowNavViewController.h"
#import "UIImage+color.h"
@interface ShowNavViewController ()

@end

@implementation ShowNavViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    //更改当前页面的,创建一个高20的假状态栏
    UIView *statusBarView = [[UIView alloc] initWithFrame:CGRectMake(0, -20, self.view.bounds.size.width, 20)];
    statusBarView.backgroundColor=[UIColor greenColor];
    [self.navigationController.navigationBar addSubview:statusBarView];
    
    //设置导航栏透明 （见编译效果）
    //1、设置透明为true
   [self.navigationController.navigationBar setTranslucent:YES];
    //2/设置一张空的图片作为背景图片
    [self.navigationController.navigationBar setBackgroundImage:[[UIImage alloc]init] forBarMetrics:UIBarMetricsDefault];
    //3、清除边框，设置一张空的图片(导航栏下面的线)，不过最好用下方的方法，寻找lineview进行隐藏
    //3-1 此方法可以将线隐藏，但是一旦隐藏则不好添加上去
//    [self.navigationController.navigationBar setShadowImage:[[UIImage alloc]init]];
    //3-2 此方法为寻找线，设置其hidden 属性
    if([self findlineviw:self.navigationController.navigationBar])
    {
        [self findlineviw:self.navigationController.navigationBar].hidden = YES;
    }
}
//获取导航栏底部的线
-(UIImageView*)findlineviw:(UIView*)view{
    
    if ([view isKindOfClass:[UIImageView class]]&&view.bounds.size.height<=1.0) {
        return (UIImageView*) view;
    }for (UIImageView *subview in view.subviews) {
        UIImageView *lineview = [self findlineviw:subview];
        if (lineview) {
            return lineview;
        }
    }
    return nil;
}
-(void)viewDidDisappear:(BOOL)animated
{
    [super viewDidDisappear:animated];
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
